<%@page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<% 
			String basepath = request.getContextPath();
		%>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link href="<%=basepath%>/css/nomal.css" rel="stylesheet" type="text/css" />
		<link href="<%=basepath%>/css/register.css" rel="stylesheet" type="text/css" />
		<script language="javascript" type="text/javascript" src="<%=basepath%>/js/include.js"></script>
		<script src="js/jquery-1.4.4.js" type="text/javascript"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/js/utilTool.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basepath%>/js/validatorTool.js"></script>


<style type="text/css">
.mycolor {
	color: #FF0000;
}
</style> 

<script type="text/javascript">
		//这里进行提交
function preStep() {
	//首先进行页面的JS验证
	//var valid = checkSupInfo(4);
	//if(valid ==false){
	//	return false;
	//}
	
	document.forms[0].action = "<%=basepath %>/selfinfo/editPreStep?preStep=3";
	document.forms[0].submit();
}

function commit(){
	//var valid = checkSupInfo(4);
	//if(valid ==false){
	//	return false;
	//}
	document.forms[0].action = "<%=basepath %>/selfinfo/commitSupInfo";
	document.forms[0].submit();
}
	
function initBankType(id){
	var url = "iframe:<%=basepath%>/register/initBankTypeList?id="+id;
	dialog("", url,"500", "400", "","");
}
function initBankDoc(id,index){
	var pkBankType=document.getElementById("bankType"+index).value;
	if(pkBankType==null || pkBankType==""){
		alert("请选择银行类别");
		return;
	}
	var url = "iframe:<%=basepath%>/register/initBankDocList?id="+id+"&pkBankType="+pkBankType;
	dialog("", url,"500", "400", "","");
}

function initCurType(id){
	var url = "iframe:<%=basepath%>/register/initCurTypeList?id="+id;
	dialog("", url,"500", "400", "","");
}

//行号
var bankTypeIndex=${bankRows};

function addBankInfo() {
	var bankInfo = document.all("bankInfo");
	var newRowIndex = bankInfo.rows.length;
	
	if(bankInfo != null) {
 		var row = bankInfo.insertRow();
 		bankTypeIndex++;
	 	row.style.height = '26px';
	 	row.id = "row"+bankTypeIndex;

		//序号
		var cell = row.insertCell()
		cell.innerHTML = "<input type='text' class='list_text_2' name='index' value='"+(newRowIndex)+"'  readOnly/>";

		//银行账户
		var cell = row.insertCell()
		cell.innerHTML = "<input type='text' class='list_text_2' name='supaccount' />";
		
		//银行户名	
 		cell = row.insertCell()
 		cell.align = 'center';
 		cell.innerHTML = "<input type='text' class='list_text_2' name='accountname'/>";
 		
 		//银行分类名称
 		var cellId="bankType"+bankTypeIndex;
 		var cellName=cellId+"name";
 		cell = row.insertCell();
 		cell.align = 'center';
 		cell.innerHTML = "<input type='text' class='list_text_2' name='bankTypeName' id='"+cellName+"' onclick=\"initBankType('"+cellId+"')\" readOnly />";

		 //开户银行说明
		var cellId="bankDoc"+bankTypeIndex;
 		var cellName=cellId+"name";
 		cell = row.insertCell();
 		cell.align = 'center';
 		cell.innerHTML = "<input type='text' class='list_text_2' name='bankDocName' id='"+cellName+"' onclick=\"initBankDoc('"+cellId+"',"+bankTypeIndex+")\" readOnly/>";

 		//币种名称
 		var cellId="curtype"+bankTypeIndex;
 		var cellName=cellId+"name";
 		cell = row.insertCell();
 		cell.align = 'center';
 		cell.innerHTML = "<input type='text' name='currencyName' id='"+cellName+"' onclick=\"initCurType('"+cellId+"')\" readOnly class='list_text_2'/>";
 		
 		//删除操作
 		var cellId="bankType"+bankTypeIndex;
 		var bankCellId="bankDoc"+bankTypeIndex;
 		var cellName=cellId+"name";
 		cell = row.insertCell();
 		cell.align = 'center';   
 		cell.innerHTML = "<a id='row${bank.index}' href=\"javascript:deleteRow('"+bankTypeIndex+"')\" class='linkstyle3'>删除</a>" 
 		                 + "<input type='hidden' name='bankTypeId' id='"+cellId+"'/><input type='hidden' name='pkBankDoc' id='"+bankCellId+"'/><input type='hidden' name='pkCurrency' id='curtype"+bankTypeIndex+"'/><input type='hidden' name='src_bankbas' /><input type='hidden' name='pk_supbankacc' />";
 		
 		
 	}
}
//删除行
function deleteRow(index) {
	var root = document.all("bankInfo");
	var row = "row"+index ;
	var rows = root.rows;
	//寻找到对应的删除行并进行删除
	for(var pos = 1; pos < rows.length; pos++) {
		var temprow = rows[pos];
		if(temprow.id == row) {
			root.deleteRow(pos);
			break;
		}
	}
	//当删除行操作时更新显示索引
	for(var pos = 1; pos < rows.length; pos++) {
		var temprow = rows[pos];
		var cells = temprow.cells;
		var cell = cells[0];
		if(typeof(cell) == 'object') {
			cell.innerHTML = "<input type='text' class='list_text_2' name='index' value='"+pos+"' readOnly/>";
		}
	}	
}
</script>
</head>
	<body class="fullbody">
		<div class="context">
					<div class="position">
						<div class="tposi">
							当前位置：
							<a href="javascript:changeMenu(1,'<%=request.getContextPath()%>/infopub/pubmain?menuid=1');" class="linkstyle">首页</a>&nbsp;&gt;&gt;&nbsp;
							<a href="javascript:changeMenu(4,'')" class="linkstyle">自助服务</a>&nbsp;&gt;&gt;&nbsp;
							<span class="curposition">企业信息维护</span>
						</div>
						<div class="help">
							<a href="javascript:void(null);" onclick="doHelp('<%=request.getContextPath()%>/help/html/QYXXXG.html');" class="linkstyle">帮助</a>
						</div>
					</div>
					<div class="margin8"> </div>
					<div class="subpage_title">
						<div class="title_index">
							<img src="<%=basepath%>/images/common/dot03.gif" alt="" border="0" /> &nbsp;企业信息维护
						</div>
						<div class="rollback">
							<a href="javascript:changeMenu(4,'')" class="linkstyle">&lt;&lt;&nbsp;返回自助服务</a>
						</div>
					</div>
					<div class="margin10">
					</div>
					<!--<div class="orginfo">
                        --><c:if test="${currentInfo.isReadAfterAudit==null ||currentInfo.isReadAfterAudit==\"N\"}">
							<div class="spliter_line"> </div>
							<div class="margin10"> </div>
							<div class="message">
	                            <img src="<%=basepath%>/images/account/msg.png" alt="" />&nbsp;信息修改已通过审核，您的企业信息已经更新！
	                        </div>
                        </c:if>
                        <div class="spliter_line"> </div>
						<div class="subpage_title_small">
							注：企业信息修改后需要提交采购方审核。<font class="memoTh"> (此银行帐号供付款和收付投标保证金使用)</font>
						</div>
							<div class="productlist" > 
								<form method="post" >
									<table border="0" cellpadding="0" cellspacing="0" id="bankInfo"
										class="subpage_table1 withborder2" align="center" width="700">
										<tr>
											<th class="w_04">序号</th>
											<th class="w_05" >银行账号<span class="needfill">*</span></th>
											<th class="w_05" >账户名称<span class="needfill">*</span></th>
											<th class="w_02" >银行类别<span class="needfill">*</span></th>
											<th class="w_02" >开户银行</th>
											<th class="w_02" >币种<span class="needfill">*</span></th>
											<th class="w_01" >操作</th>
										</tr>
										<c:if test="${currentInfo!=null && currentInfo.bankAccVos!=null}">
											<c:forEach items="${currentInfo.bankAccVos}" var="bank" varStatus="index">
												<tr align="center" class="datarow" id="row${bank.index}">
													<td>
														<input type="text" class="list_text_2" name="index" value="${bank.index}" id="index" readOnly/>
													</td>
													<c:if test="${bank.pk_supbankacc!=null && ''!=bank.pk_supbankacc}">
													
													<td>
														<input type="text" class="list_text_2" name="supaccount" value="${bank.supaccount}" id="supaccount" />
													</td>
													<td>
														<input type="text" class=list_text_2 name="accountname" value="${bank.accountname}" id="accountname" />
													</td>
													<td>
														<input type="text" class="list_text_2" name="bankTypeName" value="${bank.bankTypeName}" 
																id="bankType${bank.index}name"  onclick="initBankType('bankType${bank.index}')" readOnly />
													</td>
													<td>
														<input type="text" class="list_text_2" name="bankDocName" value="${bank.bankDocName}"
															id="bankDoc${bank.index}name" onclick="initBankDoc('bankDoc${bank.index}',${bank.index})" readOnly/>
													</td>
													<td>
														<input type="text" class="list_text_2" name="currencyName" value="${bank.currencyName}" 
																id="curtype${bank.index}name"  onclick="initCurType('curtype${bank.index}')" readOnly />
													</td>
													<td>
														<a id="row${bank.index}" href="javascript:deleteRow('${bank.index}')">删除</a>
														<input type="hidden" name="bankTypeId" value="${bank.bankTypeId}" id="bankType${bank.index}" />
														<input type="hidden" name="pkBankDoc" value="${bank.pkBankDoc}" id="bankDoc${bank.index}" />
														<input type="hidden" name="pkCurrency" value="${bank.pkCurrency}" id="curtype${bank.index}" />
														<input type="hidden" name="pk_supbankacc" value="${bank.pk_supbankacc}" id="pk_supbankacc" />
														<input type="hidden" name="src_bankbas" value="${bank.src_bankbas}"  />
													</td>
													
													</c:if>
													<c:if test="${bank.pk_supbankacc==null || ''==bank.pk_supbankacc}">
													
													<td>
														<input type="text" class="textinput" name="supaccount" value="${bank.supaccount}" id="supaccount"  />
													</td>
													<td>
														<input type="text" class="textinput" name="accountname" value="${bank.accountname}" id="accountname"  />
													</td>
													<td>
														<input type="text" class="textinput" name="bankTypeName" value="${bank.bankTypeName}" 
															id="bankType${bank.index}name" onclick="initBankType('bankType${bank.index}')"  readOnly />
													</td>
													<td>
														<input type="text" class="textinput" name="bankDocName" value="${bank.bankDocName}"
															id="bankDoc${bank.index}name" onclick="initBankDoc('bankDoc${bank.index}',${bank.index})" readOnly/>
													</td>
													<td>
														<input type="text" class="textinput" name="currencyName" value="${bank.currencyName}" 
															id="curtype${bank.index}name"  onclick="initCurType('curtype${bank.index}')" readOnly />
													</td>
													<td>
														<a id="row${bank.index}" onclick="deleteRow('${bank.index}')" >删除</a>
														<input type="hidden" name="bankTypeId" value="${bank.bankTypeId}" id="bankType${bank.index}" />
														<input type="hidden" name="pkBankDoc" value="${bank.pkBankDoc}" id="bankDoc${bank.index}" />
														<input type="hidden" name="pkCurrency" value="${bank.pkCurrency}" id="curtype${bank.index}" />
														<input type="hidden" name="pk_supbankacc" value="${bank.pk_supbankacc}" id="pk_supbankacc" />
														<input type="hidden" name="src_bankbas" value="${bank.src_bankbas}"  />
													</td>
													
													</c:if>
												</tr>
											</c:forEach>
										</c:if>
									</table>
								</form>
								<br/><br/>
								<table border="0" cellpadding="0" cellspacing="0"  align="center" width="600">
									<tr class="buttonrow" >
										<td align="center" colspan="4" align="center" >
											<input type="button" value="增行" onclick="addBankInfo()" class="btnscs"/>
											&nbsp;&nbsp;
											<input type="button"  class="btnscs" value="提交" onclick="commit();" />
											&nbsp;&nbsp;
											<input type="button" value="上一步" onclick="preStep();" class="btnscs" />
										</td>
									</tr>
								</table>
								<br/>
							</div>
						</div>
						<div class="margin20">
						<div id="message" class="mycolor">
							<c:out value="${ERROR_MESSAGE}"></c:out>
						</div>
					</div>
				<!--</div>
			--><div class="margin10"> </div>
	</body>	